package com.xxw.yygh.hosp.controller.user;


import com.xxw.yygh.common.result.R;
import com.xxw.yygh.hosp.service.ScheduleService;
import com.xxw.yygh.model.hosp.Schedule;
import com.xxw.yygh.vo.hosp.ScheduleOrderVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user/hosp/schedule")
public class UserScheduleController {

    @Resource
    private ScheduleService scheduleService;

    @GetMapping("/{hoscode}/{depcode}/{pageNum}/{pageSize}")
    public R getSchedulePage(@PathVariable String hoscode,
                             @PathVariable String depcode,
                             @PathVariable Integer pageNum,
                             @PathVariable Integer pageSize){
        Map<String,Object> map =scheduleService.getSchedulePageByCondition(hoscode,depcode,pageNum,pageSize);
        return R.ok().data(map);
    }

    //查询某一天医生的信息
    @GetMapping("/{hoscode}/{depcode}/{workDate}")
    public R getScheduleDetail(@PathVariable String hoscode,
                               @PathVariable String depcode,
                               @PathVariable String workDate){

        List<Schedule> details = scheduleService.detail(hoscode, depcode, workDate);
        return R.ok().data("detail",details);

    }

    //根据排班id获取排班信息
    @GetMapping("/info/{scheduleId}")
    public R getScheduleInfo(@PathVariable String scheduleId){
        Schedule schedule=scheduleService.getScheduleInfo(scheduleId);
        return R.ok().data("schedule",schedule);
    }

    //Order远程调用接口，不建议接口复用，可以方法复用
    @GetMapping("/{scheduleId}")
    public ScheduleOrderVo getScheduleById(@PathVariable(value = "scheduleId") String scheduleId){
        return scheduleService.getScheduleById(scheduleId);
    }

}
